//
//  AdornAddGoodsCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/8/9.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "AdornAddGoodsCell.h"

@interface AdornAddGoodsCell ()
@property (nonatomic, strong) UIView *contenBg;
@property (nonatomic, strong) UIImageView *headImage;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *moneyLabel;
@property (nonatomic, strong) UIImageView *selectImage;

@end

@implementation AdornAddGoodsCell

+ (AdornAddGoodsCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"AdornAddGoodsCell";
    AdornAddGoodsCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[AdornAddGoodsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.contenBg = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), 0, SCREEN_WIDTH - ScreenX375(58), ScreenX375(72))];
    self.contenBg.layer.cornerRadius = ScreenX375(5);
    self.contenBg.clipsToBounds = YES;
    self.contenBg.layer.borderWidth = 1;
    [self addSubview:self.contenBg];
    
    self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(103), ScreenX375(71))];
    [self.contenBg addSubview:self.headImage];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(115), ScreenX375(8), ScreenX375(180), ScreenX375(16))];
    self.nameLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.nameLabel.font = Kfont(14);
    [self.contenBg addSubview:self.nameLabel];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(115), ScreenX375(29), ScreenX375(180), ScreenX375(18))];
    self.detailLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.detailLabel.font = Kfont(12);
    [self.contenBg addSubview:self.detailLabel];
    
    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(115), ScreenX375(48), ScreenX375(180), ScreenX375(18))];
    self.moneyLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.moneyLabel.font = Kfont(12);
    [self.contenBg addSubview:self.moneyLabel];
    
    self.selectImage = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(85.5), ScreenX375(44.5), ScreenX375(27.5), ScreenX375(27.5))];
    self.selectImage.image = [UIImage imageNamed:@"矩形2"];
    self.selectImage.hidden = YES;
    [self.contenBg addSubview:self.selectImage];
    
    UIImageView *selectImageC = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(11.5), ScreenX375(14.5), ScreenX375(14), ScreenX375(9))];
    selectImageC.image = [UIImage imageNamed:@"勾选白色"];
    [self.selectImage addSubview:selectImageC];
}

- (void)setStatus:(BOOL)isSelect andModel:(ShopGoodsListModel *)model{
    if (isSelect) {
        self.selectImage.hidden = NO;
        self.contenBg.layer.borderColor = ThemeColor.CGColor;
    }else {
        self.selectImage.hidden = YES;
        self.contenBg.layer.borderColor = REXADECIMALCOLOR(@"#dcdcdc").CGColor;
    }
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:model.url] placeholderImage:nil options:SDWebImageRetryFailed];
    self.nameLabel.text = model.design_name;
    self.detailLabel.text = [NSString stringWithFormat:@"售价：%@元",model.price];
    self.moneyLabel.text = [NSString stringWithFormat:@"发布时间：%@",model.price];
    self.moneyLabel.hidden = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
